





//
//  MBFirstHeaderView.m
//  房源详情-小区详情
//
//  Created by MB__Lee on 2018/5/28.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "MBFirstHeaderView.h"
#import <SDCycleScrollView.h>
#import <MJExtension.h>
#import "MBHeaderModel.h"

#import "MBNetTool.h"

@interface MBFirstHeaderView()<SDCycleScrollViewDelegate>

@property(nonatomic,strong)NSMutableArray *imgURLmut;//存放轮播链接

@end

@implementation MBFirstHeaderView
-(NSMutableArray *)imgURLmut{
    if (!_imgURLmut) {
        _imgURLmut = [NSMutableArray array];
    }
    return _imgURLmut;

}
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame: frame]) {
        
        [self getBannerUrl];
    }
    return  self;
}
//头部的 广告的 信息
-(void)getBannerUrl{
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[@"city"] =  MBCityCode;
    dict[@"platform"] = @"iOS";
    dict[@"type"] =  @"1";
    
    [MBNetTool MBPost:Banner_show paramater:dict success:^(id response) {
        if ([response[@"code"] integerValue] == 10000) {
            NSMutableArray *imgURLmut  = [MBHeaderModel mj_objectArrayWithKeyValuesArray:response[@"data"]];
            
             SDCycleScrollView *cycle = [SDCycleScrollView cycleScrollViewWithFrame:self.bounds delegate:self placeholderImage:[UIImage imageNamed:@"cellPlaceHolder"]];
            cycle.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
            
            for (MBHeaderModel *model in imgURLmut) {
                [self.imgURLmut addObject:model.img];
            }
            
            cycle.imageURLStringsGroup = self.imgURLmut;
            
            [self addSubview:cycle];
            
            
        }else{
            NSLog(@"首页轮播------%@",response[@"code"]);
        }
        
        
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark ---SDCycleScrollViewDelegate
-(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    
}



@end
